<!DOCTYPE html>
<html lang="zh-CN"
      xmlns="http://www.w3.org/1999/xhtml"
      xmlns:th="http://www.thymeleaf.org">

<head>
    <meta charset="UTF-8">
    <title>欢迎页面-X-admin2.0</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <!--<link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />-->
    <link rel="stylesheet" data-th-href="@{/css/font.css}">
    <link rel="stylesheet" data-th-href="@{/css/xadmin.css}">
    <script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
    <script type="text/javascript" data-th-src="@{/lib/layui/layui.js}" charset="utf-8"></script>
    <script type="text/javascript" data-th-src="@{/js/xadmin.js}"></script>
    <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
    <!--[if lt IE 9]>
    <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
    <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
</head>

<body>
<div class="x-body">
    <form class="layui-form" id="save_form" data-th-action="@{/account/update}">
        <input type="hidden" name="id" data-th-value="${account.id}">
        <div class="layui-form-item">
            <label for="username" class="layui-form-label">
                <span class="x-red">*</span>用户名
            </label>
            <div class="layui-input-inline">
                <input type="text" id="username" name="username" disabled="disabled"
                        data-th-value="${account.username}"
                       autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label for="role" class="layui-form-label">
                <span class="x-red">*</span>角色
            </label>
            <div class="layui-input-inline">
                <select id="role" name="role">
                    <option data-th-selected="${account.role==1}" value="1">站点管理员</option>
                    <option data-th-selected="${account.role==0}" value="0">超级管理员</option>
                </select>
            </div>
        </div>

        <div class="layui-form-item">
            <button  class="layui-btn" lay-filter="update" lay-submit="update">立即提交</button>
        </div>
    </form>
</div>
<script>
    layui.use(['form','layer'], function(){
        $ = layui.jquery;
        var form = layui.form
            ,layer = layui.layer;



        form.on("submit(update)",function(data){
            var index = layer.msg('数据提交中，请稍候',{icon: 16,time:false,shade:0.8});
            var url = $("#save_form").attr("action");
            var data = $("#save_form").serializeArray(); //自动将form表单封装成json
            //console.log(url);
            setTimeout(function(){
                $.ajax({
                    type:"post",
                    url:url,
                    data:data,
                    dataType:"json",
                    success:function(result){
                        layer.close(index);
                        //console.log(result.message);
                        layer.msg(result.message);
                        //刷新父页面
//							console.log(window.location);
                        if(result.code==0){
                            setTimeout(function(){window.location.href = "/account/getlist"},2000)
                        }
                    }
                });
                layer.close(index);
            },1000);
            return false;
        })

    });
</script>
</body>
</html>